﻿<Window x:Class="MoneyManagerNET.Presentation.View.CategoryListView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="CategoriesWindow" Height="300" Width="300"
        
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d"
        
       xmlns:vm="clr-namespace:MoneyManagerNET.Presentation.ViewModel;assembly=MoneyManagerNET.Presentation.ViewModel" 
       d:DataContext="{x:Static Member=vm:DesignTimeViewModelSupplier.Categories}"
    >
    <Window.Resources>
        <Style TargetType="Button">
            <Setter Property="Margin" Value="10,4"/>
            
        </Style>


        <DataTemplate x:Key="SubCategoryTemplate" >
            <ContentControl DataContext="{Binding .,Converter={StaticResource wrapper}}">
                <TextBlock Text="{Binding Name}"/>
            </ContentControl>
        </DataTemplate>


        <HierarchicalDataTemplate x:Key="CategoryTemplate"  ItemsSource="{Binding SubCategoryList,Converter={StaticResource wrapper}}"  ItemTemplate="{StaticResource SubCategoryTemplate}">
            <ContentControl DataContext="{Binding .,Converter={StaticResource wrapper}}">
                <TextBlock Text="{Binding Name}"/>
            </ContentControl>
        </HierarchicalDataTemplate>
    </Window.Resources>
    <Grid>
       
            <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="auto" />
            <RowDefinition Height="auto" />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>

        <TreeView x:Name="tree" MouseDoubleClick="tree_MouseDoubleClick"  SelectedItemChanged="tree_SelectedItemChanged">
                
            <TreeViewItem Header="Categories" ItemTemplate="{StaticResource CategoryTemplate}" ItemsSource="{Binding Path=ItemsView}" IsExpanded="True">
                
            </TreeViewItem>

        </TreeView>
        <TextBox Grid.Row="1" Margin="4" Text="{Binding CategoryName}"></TextBox>
        <Grid Grid.Row="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Button x:Name="btnAdd" Content="Add" Command="{Binding NewCommand}" />
                
               
            <Button x:Name="btnEdit" Grid.Column="1" Content="Edit" Command="{Binding EditCommand}"/>
            <Button x:Name="btnDelete" Grid.Column="2" Content="Delete" Command="{Binding DeleteCommand}"/>
        </Grid>
        <Button x:Name="btnSelect" Grid.Row="3" Content="Select" Click="Clicked_Select" />
    </Grid>
</Window>
